﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace emlak
{
    static class snfVeritabani
    {
        //veritabanında işlem  yapabilmek için bu kısmı kendinize göre yapmanız gerekiyor.
        static private string _connectionstring = "Data Source=UURYSR-PC;Initial Catalog=projeiçi;Integrated Security=True";

        static public string Connectionstring
        {
            get { return _connectionstring; }
            set { _connectionstring = value; }
        }

        //deneme
        static public string Kisi_Ekle_Guncelle(snfMusteriKisiKayit newmusteri, string islem)
        {

            SqlConnection cnn = new SqlConnection(_connectionstring);

            SqlCommand cmd = new SqlCommand();
            cmd.Connection = cnn;
            cmd.CommandText = "Kisi_Ekle_Guncelle";
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@islem", islem);
            cmd.Parameters.AddWithValue("@tc", newmusteri.Tckimlik);
            cmd.Parameters.AddWithValue("@ad", newmusteri.Ad);
            cmd.Parameters.AddWithValue("@soyad", newmusteri.Soyad);
            cmd.Parameters.AddWithValue("@unvani", newmusteri.Unvani);
            cmd.Parameters.AddWithValue("@meslegi", newmusteri.Meslegi);
            cmd.Parameters.AddWithValue("@istel", newmusteri.Istel);
            cmd.Parameters.AddWithValue("@evtel", newmusteri.Evtel);
            cmd.Parameters.AddWithValue("@fax", newmusteri.Fax);
            cmd.Parameters.AddWithValue("@ceptel", newmusteri.Ceptel);
            cmd.Parameters.AddWithValue("@eposta", newmusteri.Email);
            cmd.Parameters.AddWithValue("@bankaadi", newmusteri.Bankadi);
            cmd.Parameters.AddWithValue("@hesapno", newmusteri.Bankahesapno);
            cmd.Parameters.AddWithValue("@dogumtarihi", newmusteri.Dogumtarihi);
            cmd.Parameters.AddWithValue("@aciklama", newmusteri.Not);
            cmd.Parameters.AddWithValue("@kayittarihi", newmusteri.Kayittarihi);
            cmd.Parameters.AddWithValue("@sondegisikligiyapan", newmusteri.SonDegisikligiYapan);
            cmd.Parameters.AddWithValue("@sondegisikliktarihi", newmusteri.SonDegisiklikTarihi);
            cmd.Parameters.AddWithValue("@il", newmusteri.Il);
            cmd.Parameters.AddWithValue("@ilce", newmusteri.Ilce);
            cmd.Parameters.AddWithValue("@semt", newmusteri.Semt);
            cmd.Parameters.AddWithValue("@detayliadres", newmusteri.Detayliadres);
            cmd.Parameters.Add("@tc", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;

            try
            {
                cnn.Open();
                cmd.ExecuteNonQuery();
                cnn.Dispose();
                cnn.Close();
            }
            catch (Exception ex) { }
            return cmd.Parameters["@tc"].Value.ToString();
        }
        //çalışıyor
        static public int EvArz_Ekle_Guncelle(snfEvArzKayit newEvArz, int islem)
        {
            SqlConnection cnn = new SqlConnection(Connectionstring);

            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "EvArz_Ekle_Guncelle";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = cnn;

            cmd.Parameters.Add("@islem", SqlDbType.Int).Value = islem;
            cmd.Parameters.Add("@islemturu", SqlDbType.Int).Value = newEvArz.IslemTuru;
            cmd.Parameters.Add("@turu", SqlDbType.Int).Value = newEvArz.Tipi;
            cmd.Parameters.Add("@binayasi", SqlDbType.Int).Value = newEvArz.Binayasi;
            cmd.Parameters.Add("@katsayisi", SqlDbType.Int).Value = newEvArz.Katsayisi;
            cmd.Parameters.Add("@isinmasekli", SqlDbType.Int).Value = newEvArz.Isinmasekli;
            cmd.Parameters.Add("@binadurumu", SqlDbType.Int).Value = newEvArz.Binadurumu;
            cmd.Parameters.Add("@imardurumu", SqlDbType.NChar, 10).Value = newEvArz.Imardurumu;
            cmd.Parameters.Add("@metrekare", SqlDbType.Int).Value = newEvArz.Metrekare;
            cmd.Parameters.Add("@evdurumu", SqlDbType.Int).Value = newEvArz.Evdurumu;


            cmd.Parameters.Add("@bulundugukat", SqlDbType.Int).Value = newEvArz.Bulundugukat;
            cmd.Parameters.Add("@odasayisi", SqlDbType.Int).Value = newEvArz.Odasayisi;
            cmd.Parameters.Add("@aciklama_evbilgi", SqlDbType.NChar, 200).Value = newEvArz.Evbilgiaciklama;
            cmd.Parameters.Add("@asansor", SqlDbType.Int).Value = newEvArz.Asansor;
            cmd.Parameters.Add("@kiler", SqlDbType.Int).Value = newEvArz.Kiler;
            cmd.Parameters.Add("@kablolutv", SqlDbType.Int).Value = newEvArz.Kablolutv;
            cmd.Parameters.Add("@komurluk", SqlDbType.Int).Value = newEvArz.Komurluk;
            cmd.Parameters.Add("@uydu", SqlDbType.Int).Value = newEvArz.Uydu;
            cmd.Parameters.Add("@gunesenerjisi", SqlDbType.Int).Value = newEvArz.Gunesenerjisi;
            cmd.Parameters.Add("@catikati", SqlDbType.Int).Value = newEvArz.Catikati;


            cmd.Parameters.Add("@diafon", SqlDbType.Int).Value = newEvArz.Diafon;
            cmd.Parameters.Add("@kapici", SqlDbType.Int).Value = newEvArz.Kapici;
            cmd.Parameters.Add("@hidrafor", SqlDbType.Int).Value = newEvArz.Hidrafor;
            cmd.Parameters.Add("@otopark", SqlDbType.Int).Value = newEvArz.Otopark;
            cmd.Parameters.Add("@vestiyer", SqlDbType.Int).Value = newEvArz.Vestiyer;
            cmd.Parameters.Add("@gommedolap", SqlDbType.Int).Value = newEvArz.Gommedolap;
            cmd.Parameters.Add("@balkon", SqlDbType.Int).Value = newEvArz.Balkon;
            cmd.Parameters.Add("@kartonpiyer", SqlDbType.Int).Value = newEvArz.Kartonpiyer;
            cmd.Parameters.Add("@celikkapi", SqlDbType.Int).Value = newEvArz._Celikkapi;
            cmd.Parameters.Add("@klima", SqlDbType.Int).Value = newEvArz.Klima;


            cmd.Parameters.Add("@mobilyali", SqlDbType.Int).Value = newEvArz.Mobilya;
            cmd.Parameters.Add("@teras", SqlDbType.Int).Value = newEvArz.Teras;
            cmd.Parameters.Add("@isicam", SqlDbType.Int).Value = newEvArz.Isicam;
            cmd.Parameters.Add("@somine", SqlDbType.Int).Value = newEvArz.Somine;
            cmd.Parameters.Add("@dusakabin", SqlDbType.Int).Value = newEvArz.Duskabin;
            cmd.Parameters.Add("@barbeku", SqlDbType.Int).Value = newEvArz.Barbeku;
            cmd.Parameters.Add("@aciklama_genelozellikler", SqlDbType.NChar, 200).Value = newEvArz.Ozellikaciklama;
            cmd.Parameters.Add("@bahce", SqlDbType.Int).Value = newEvArz.Bahce;
            cmd.Parameters.Add("@isiyalitim", SqlDbType.Int).Value = newEvArz.Isiyalitimi;
            cmd.Parameters.Add("@guvenlik", SqlDbType.Int).Value = newEvArz.Guvenlik;


            cmd.Parameters.Add("@pvcdograma", SqlDbType.Int).Value = newEvArz.Pcvdograma;
            cmd.Parameters.Add("@kooperatifadi", SqlDbType.NChar, 40).Value = newEvArz.Koopad;
            cmd.Parameters.Add("@baskani", SqlDbType.NChar, 50).Value = newEvArz.Koopbaskan;
            cmd.Parameters.Add("@tel1", SqlDbType.NChar, 10).Value = newEvArz.Telno1;
            cmd.Parameters.Add("@tel2", SqlDbType.NChar, 10).Value = newEvArz.Telno2;
            cmd.Parameters.Add("@kayittarihi", SqlDbType.DateTime).Value = DBNull.Value;
            cmd.Parameters.Add("@sondegisikligiyapan", SqlDbType.Int).Value = DBNull.Value;
            cmd.Parameters.Add("@sondegisikliktarihi", SqlDbType.DateTime).Value = DBNull.Value;
            cmd.Parameters.Add("@resim1", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim2", SqlDbType.Text).Value = DBNull.Value;


            cmd.Parameters.Add("@resim3", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim4", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim5", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim6", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim7", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim8", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@islemgordu", SqlDbType.Int).Value = newEvArz.Islemgordu;

            // kontrol için gerekli bilgiler
            cmd.Parameters.Add("@il", SqlDbType.NChar, 20).Value = newEvArz.Il;
            cmd.Parameters.Add("@ilce", SqlDbType.NChar, 30).Value = newEvArz.Ilce;
            cmd.Parameters.Add("@semt", SqlDbType.NChar, 30).Value = newEvArz.Semt;
            cmd.Parameters.Add("@detayliadres", SqlDbType.NChar, 200).Value = newEvArz.Detayadres;

            cmd.Parameters.Add("@tc", SqlDbType.NChar, 11).Value = newEvArz.Tc;
            cmd.Parameters.Add("@tabloadi", SqlDbType.NChar, 20).Value = "tblEvArz";
            cmd.Parameters.Add("@depozito", SqlDbType.Money).Value = newEvArz.Depozito;
            cmd.Parameters.Add("@fiyat1", SqlDbType.Money).Value = newEvArz.Fiyat1;
            cmd.Parameters.Add("@fiyat2", SqlDbType.Money).Value = newEvArz.Fiyat2;
            cmd.Parameters.Add("@odemesekli", SqlDbType.Int).Value = newEvArz.Odemesekli;
            cmd.Parameters.Add("@kiramiktari", SqlDbType.Money).Value = newEvArz.Kiramiktari;
            cmd.Parameters.Add("@odemeaciklama", SqlDbType.NChar, 200).Value = newEvArz.Odemeaciklama;
            cmd.Parameters.Add("@dovizkuru", SqlDbType.Int).Value = newEvArz.Dovizkuru;
            cmd.Parameters.Add("@ilanID", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;

            try
            {
                cnn.Open();
                cmd.ExecuteNonQuery();
                cnn.Dispose();
                cnn.Close();
            }
            catch (Exception ex) { }

            return Convert.ToInt32(cmd.Parameters["@ilanID"].Value);
        }

        static public int IsyeriArz_Ekle_Guncelle(snfIsyeriArzKayit newIsyeriArz, int islem)
        {
            SqlConnection cnn = new SqlConnection(Connectionstring);

            SqlCommand cmd = new SqlCommand();
            cmd.Connection = cnn;
            cmd.CommandText = "IsyeriArz_Ekle_Guncelle";
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@islem", SqlDbType.Int).Value = islem;
            cmd.Parameters.Add("@islemturu", SqlDbType.Int).Value = newIsyeriArz.Islemtip;
            cmd.Parameters.Add("@emlakdurumu", SqlDbType.Int).Value = newIsyeriArz.Emlakdurumu;
            cmd.Parameters.Add("@binatipi", SqlDbType.Int).Value = newIsyeriArz.Binatipi;
            cmd.Parameters.Add("@binayasi", SqlDbType.Int).Value = newIsyeriArz.Binayasi;
            cmd.Parameters.Add("@katsayisi", SqlDbType.Int).Value = newIsyeriArz.Binakatsayisi;
            cmd.Parameters.Add("@isinmasekli", SqlDbType.Int).Value = newIsyeriArz.Isinmasekli;
            cmd.Parameters.Add("@binadurumu", SqlDbType.Int).Value = newIsyeriArz.Binadurumu;
            cmd.Parameters.Add("@imardurumu", SqlDbType.NChar, 10).Value = newIsyeriArz.Imardurumu;
            cmd.Parameters.Add("@turu", SqlDbType.Int).Value = newIsyeriArz.Turu;

            cmd.Parameters.Add("@isyeridurumu", SqlDbType.Int).Value = newIsyeriArz.Isyeridurumu;
            cmd.Parameters.Add("@zemin", SqlDbType.Int).Value = newIsyeriArz.Zemin;
            cmd.Parameters.Add("@metrekare", SqlDbType.Int).Value = newIsyeriArz.Metrekare;
            cmd.Parameters.Add("@odasayisi", SqlDbType.Int).Value = newIsyeriArz.Odasayisi;
            cmd.Parameters.Add("@bulundugukat", SqlDbType.Int).Value = newIsyeriArz.Bulundugukat;
            cmd.Parameters.Add("@mutfak", SqlDbType.Int).Value = newIsyeriArz.Mutfak;
            cmd.Parameters.Add("@calisan", SqlDbType.Int).Value = newIsyeriArz.Calisan;
            cmd.Parameters.Add("@asansor", SqlDbType.Int).Value = newIsyeriArz.Asansor;
            cmd.Parameters.Add("@gunesenerjisi", SqlDbType.Int).Value = newIsyeriArz.Gunesenerji;
            cmd.Parameters.Add("@alarmsistemi", SqlDbType.Int).Value = newIsyeriArz.Alarmsistem;

            cmd.Parameters.Add("@vitrin", SqlDbType.Int).Value = newIsyeriArz.Vitrin;
            cmd.Parameters.Add("@kamerasistemi", SqlDbType.Int).Value = newIsyeriArz.Kamerasistem;
            cmd.Parameters.Add("@vestiyer", SqlDbType.Int).Value = newIsyeriArz.Vestiyer;
            cmd.Parameters.Add("@yanginmerdiveni", SqlDbType.Int).Value = newIsyeriArz.Yanginmerdiven;
            cmd.Parameters.Add("@fax", SqlDbType.NChar, 10).Value = newIsyeriArz.Fax;
            cmd.Parameters.Add("@telefon", SqlDbType.NChar, 10).Value = newIsyeriArz.Telefon;
            cmd.Parameters.Add("@wc", SqlDbType.Int).Value = newIsyeriArz.Wc;
            cmd.Parameters.Add("@camgiydirme", SqlDbType.Int).Value = newIsyeriArz.Camgiydirme;
            cmd.Parameters.Add("@klima", SqlDbType.Int).Value = newIsyeriArz.Klima;
            cmd.Parameters.Add("@otopark", SqlDbType.Int).Value = newIsyeriArz.Otopark;

            cmd.Parameters.Add("@jenerator", SqlDbType.Int).Value = newIsyeriArz.Jenerator;
            cmd.Parameters.Add("@aciklama_genelozelliker", SqlDbType.NChar, 200).Value = newIsyeriArz.Genelaciklama;
            cmd.Parameters.Add("@bahce", SqlDbType.Int).Value = newIsyeriArz.Bahce;
            cmd.Parameters.Add("@guvenlik", SqlDbType.Int).Value = newIsyeriArz.Guvenlik;
            cmd.Parameters.Add("@isiyalitim", SqlDbType.Int).Value = newIsyeriArz.Isiyalitim;
            cmd.Parameters.Add("@pvcdograma", SqlDbType.Int).Value = newIsyeriArz.Pvcdograma;
            cmd.Parameters.Add("@hidrafor", SqlDbType.Int).Value = newIsyeriArz.Hidrafor;
            cmd.Parameters.Add("@aciklama_fizikselozellikler", SqlDbType.NChar, 200).Value = newIsyeriArz.Fizikselaciklama;
            cmd.Parameters.Add("@kayittarihi", SqlDbType.DateTime).Value = newIsyeriArz.Kayittarihi;
            cmd.Parameters.Add("@sondegisikligiyapan", SqlDbType.Int).Value = newIsyeriArz.Sondegyap;

            cmd.Parameters.Add("@sondegisikliktarihi", SqlDbType.DateTime).Value = newIsyeriArz.Sondegtarihi;
            // resim eklenince yeniden düzeltilecek
            cmd.Parameters.Add("@resim1", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim2", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim3", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim4", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim5", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim6", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim7", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim8", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@islemgordu", SqlDbType.Int).Value = newIsyeriArz.Islemgordu;

            cmd.Parameters.Add("@notu", SqlDbType.NChar, 200).Value = newIsyeriArz.Notu;

            // Veri kontrolü yapıldıktan sonra düzeltilecek.
            cmd.Parameters.Add("@il", SqlDbType.NChar, 20).Value = newIsyeriArz.Il;
            cmd.Parameters.Add("@ilce", SqlDbType.NChar, 30).Value = newIsyeriArz.Ilce;
            cmd.Parameters.Add("@semt", SqlDbType.NChar, 30).Value = newIsyeriArz.Semt;
            cmd.Parameters.Add("@detayliadres", SqlDbType.NChar, 200).Value = newIsyeriArz.Detayadres;

            cmd.Parameters.Add("@tc", SqlDbType.NChar, 11).Value = newIsyeriArz.Tc;
            cmd.Parameters.Add("@tabloadi", SqlDbType.NChar, 20).Value = "tblIsyeriBuroArz";

            cmd.Parameters.Add("@depozito", SqlDbType.Money).Value = newIsyeriArz.Depozito;
            cmd.Parameters.Add("@fiyat1", SqlDbType.Money).Value = newIsyeriArz.Fiyat1;
            cmd.Parameters.Add("@fiyat2", SqlDbType.Money).Value = newIsyeriArz.Fiyat2;

            cmd.Parameters.Add("@odemesekli", SqlDbType.Int).Value = newIsyeriArz.Odemesekli;
            cmd.Parameters.Add("@kiramiktari", SqlDbType.Money).Value = newIsyeriArz.Kiramiktari;
            cmd.Parameters.Add("@odemeaciklama", SqlDbType.NChar, 200).Value = newIsyeriArz.Odemeaciklama;
            cmd.Parameters.Add("@dovizkuru", SqlDbType.Int).Value = newIsyeriArz.Dovizkuru;

            cmd.Parameters.Add("@ret", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;

            try
            {
                cnn.Open();
                cmd.ExecuteNonQuery();
                cnn.Dispose();
                cnn.Close();
            }
            catch (Exception ex) { }

            return 0;
        }

        static public int ArsaArz_Ekle_Guncelle(snfArsaArzKayit newArsaArz, int islem)
        {
            SqlConnection cnn = new SqlConnection(Connectionstring);

            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "ArsaArz_Ekle_Guncelle";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = cnn;

            cmd.Parameters.Add("@islem", SqlDbType.Int).Value = islem;
            cmd.Parameters.Add("@islemturu", SqlDbType.Int).Value = newArsaArz.Islemturu;
            cmd.Parameters.Add("@emlakdurumu", SqlDbType.Int).Value = newArsaArz.Emlakdurumu;
            cmd.Parameters.Add("@turu", SqlDbType.Int).Value = newArsaArz.Turu;
            cmd.Parameters.Add("@imardurumu", SqlDbType.NChar, 10).Value = newArsaArz.Imardurumu;
            cmd.Parameters.Add("@metrekare", SqlDbType.Int).Value = newArsaArz.Metrekare;
            cmd.Parameters.Add("@birimfiyat", SqlDbType.Money).Value = newArsaArz.Birimfiyat;
            cmd.Parameters.Add("@mucavir", SqlDbType.Int).Value = newArsaArz.Mucavir;
            cmd.Parameters.Add("@katkarsiligi", SqlDbType.Int).Value = newArsaArz.Katkarsiligi;
            cmd.Parameters.Add("@ilgilibelediye", SqlDbType.NChar, 40).Value = newArsaArz.Belediye;
            cmd.Parameters.Add("@arsaaraziaciklama", SqlDbType.NChar, 200).Value = newArsaArz.Arsaaraziarzaciklama;
            cmd.Parameters.Add("@kayittarihi", SqlDbType.DateTime).Value = newArsaArz.Kayittarihi;
            cmd.Parameters.Add("@sondegisikligiyapan", SqlDbType.Int).Value = newArsaArz.Sondegisiklikyapan;
            cmd.Parameters.Add("@sondegisikliktarihi", SqlDbType.DateTime).Value = newArsaArz.Sondegisikliktarihi;
            cmd.Parameters.Add("@resim1", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim2", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim3", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim4", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim5", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim6", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim7", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@resim8", SqlDbType.Text).Value = DBNull.Value;
            cmd.Parameters.Add("@islemgordu", SqlDbType.Int).Value = newArsaArz.Islemgordu;
            cmd.Parameters.Add("@il", SqlDbType.NChar, 20).Value = newArsaArz.Il;
            cmd.Parameters.Add("@ilce", SqlDbType.NChar, 30).Value = newArsaArz.Ilce;
            cmd.Parameters.Add("@semt", SqlDbType.NChar, 30).Value = newArsaArz.Semt;
            cmd.Parameters.Add("@detayliadres", SqlDbType.NChar, 200).Value = newArsaArz.Detayliadres;
            cmd.Parameters.Add("@tc", SqlDbType.NChar, 11).Value = newArsaArz.Tc;
            cmd.Parameters.Add("@tabloadi", SqlDbType.NChar, 200).Value = "tblArsaArz";
            cmd.Parameters.Add("@depozito", SqlDbType.Money).Value = newArsaArz.Depozito;
            cmd.Parameters.Add("@fiyat1", SqlDbType.Money).Value = newArsaArz.Fiyat1;
            cmd.Parameters.Add("@fiyat2", SqlDbType.Money).Value = newArsaArz.Fiyat2;
            cmd.Parameters.Add("@odemesekli", SqlDbType.Int).Value = newArsaArz.Odemesekli;
            cmd.Parameters.Add("@kiramiktari", SqlDbType.Money).Value = newArsaArz.Kiramiktari;
            cmd.Parameters.Add("@odemeaciklama", SqlDbType.NChar, 200).Value = newArsaArz.Odemeaciklama;
            cmd.Parameters.Add("@dovizkuru", SqlDbType.Int).Value = newArsaArz.Dovizkuru;

            try
            {
                cnn.Open();
                cmd.ExecuteNonQuery();
                cnn.Dispose();
                cnn.Close();
            }
            catch (Exception ex) { }

            return 0;


        }

        static public int ArsaTalep_Ekle_Guncelle(snfTalepArsaKayit newArsaTalep, int islem)
        {
            SqlConnection cnn = new SqlConnection(Connectionstring);

            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "ArsaTalep_Ekle_Guncelle";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = cnn;

            cmd.Parameters.Add("@islem", SqlDbType.Int).Value = islem;
            cmd.Parameters.Add("@emlakdurum", SqlDbType.Int).Value = newArsaTalep.EmlakDurumu;
            cmd.Parameters.Add("@emlakturu", SqlDbType.Int).Value = newArsaTalep.EmlakTuru;
            cmd.Parameters.Add("@metrekare1", SqlDbType.Int).Value = newArsaTalep.Metrekare1;
            cmd.Parameters.Add("@metrekare2", SqlDbType.Int).Value = newArsaTalep.Metrekare2;
            cmd.Parameters.Add("@fiyat1", SqlDbType.Money).Value = newArsaTalep.Fiyat1;
            cmd.Parameters.Add("@fiyat2", SqlDbType.Money).Value = newArsaTalep.Fiyat2;
            cmd.Parameters.Add("@kira1", SqlDbType.Money).Value = DBNull.Value;
            cmd.Parameters.Add("@kira2", SqlDbType.Money).Value = DBNull.Value;
            cmd.Parameters.Add("@aciklama", SqlDbType.NChar, 200).Value = DBNull.Value;
            cmd.Parameters.Add("@kayittarihi", SqlDbType.DateTime).Value = newArsaTalep.KayitTarihi;
            cmd.Parameters.Add("@sondegisikligiyapan", SqlDbType.Int).Value = DBNull.Value;
            cmd.Parameters.Add("@sondegisikliktarihi", SqlDbType.DateTime).Value = DBNull.Value;
            cmd.Parameters.Add("@islemturu", SqlDbType.Int).Value = newArsaTalep.IslemTuru;
            cmd.Parameters.Add("@dovizkuru", SqlDbType.Int).Value = newArsaTalep.DovizTuru;
            cmd.Parameters.Add("@il", SqlDbType.Text).Value = newArsaTalep.Il;
            cmd.Parameters.Add("@ilce", SqlDbType.Text).Value = newArsaTalep.Ilce;
            cmd.Parameters.Add("@semt", SqlDbType.Text).Value = newArsaTalep.SemtMahalle;
            //cmd.Parameters.Add("@tc", SqlDbType.NChar, 11).Value =  newArsaTalep
            //cmd.Parameters.Add("@tabloadi", SqlDbType.NChar, 20).Value =  newArsaTalep

            try
            {
                cnn.Open();
                cmd.ExecuteNonQuery();
                cnn.Dispose();
                cnn.Close();
            }
            catch (Exception ex) { }

            return 0;
        }

        static public int EvTalep_Ekle_Guncelle(snfTalepEvKayit newEvTalep, int islem)
        {
            SqlConnection cnn = new SqlConnection(Connectionstring);

            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "EvTalep_Ekle_Guncelle";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = cnn;

            cmd.Parameters.Add("@islem", SqlDbType.Int).Value = islem;
            cmd.Parameters.Add("@emlakdurumu", SqlDbType.Int).Value = DBNull.Value;
            cmd.Parameters.Add("@binatipi", SqlDbType.Int).Value = newEvTalep.BinaTipi;
            cmd.Parameters.Add("@binakat1", SqlDbType.Int).Value = newEvTalep.BinaKat1;
            cmd.Parameters.Add("@binakat2", SqlDbType.Int).Value = newEvTalep.BinaKat2;
            cmd.Parameters.Add("@isinmasekli", SqlDbType.Int).Value = newEvTalep.IsinmaTuru;
            cmd.Parameters.Add("@metrekare1", SqlDbType.Int).Value = DBNull.Value;
            cmd.Parameters.Add("@metrekare2", SqlDbType.Int).Value = DBNull.Value;
            cmd.Parameters.Add("@odasayisi1", SqlDbType.Int).Value = newEvTalep.OdaSayisi1;
            cmd.Parameters.Add("@odasayisi2", SqlDbType.Int).Value = newEvTalep.OdaSayisi2;
            cmd.Parameters.Add("@fiyat1", SqlDbType.Money).Value = newEvTalep.Fiyat1;
            cmd.Parameters.Add("@fiyat2", SqlDbType.Money).Value = newEvTalep.Fiyat2;
            cmd.Parameters.Add("@kira1", SqlDbType.Money).Value = DBNull.Value;
            cmd.Parameters.Add("@kira2", SqlDbType.Money).Value = DBNull.Value;
            cmd.Parameters.Add("@kayittarihi", SqlDbType.DateTime).Value = DBNull.Value;
            cmd.Parameters.Add("@sondegisikligiyapan", SqlDbType.Int).Value = DBNull.Value;
            cmd.Parameters.Add("@sondegisikliktarihi", SqlDbType.DateTime).Value = DBNull.Value;
            cmd.Parameters.Add("@dovizkuru", SqlDbType.Int).Value = newEvTalep.DovizTuru;
            cmd.Parameters.Add("@il", SqlDbType.NChar, 20).Value = newEvTalep.Il;
            cmd.Parameters.Add("@ilce", SqlDbType.NChar, 30).Value = newEvTalep.Ilce;
            cmd.Parameters.Add("@semt", SqlDbType.NChar, 30).Value = newEvTalep.SemtMahalle;
            //cmd.Parameters.Add("@tc",SqlDbType.NChar, 11).Value=newEvTalep
            //cmd.Parameters.Add("@tabloadi",SqlDbType.NChar, 20).Value=newEvTalep


            try
            {
                cnn.Open();
                cmd.ExecuteNonQuery();
                cnn.Dispose();
                cnn.Close();
            }
            catch (Exception ex) { }

            return 0;
        }

        static public int IsyeriTalep_Ekle_Guncelle(snfTalepIsyeriKayit newIsyeriTalep, int islem)
        {
            SqlConnection cnn = new SqlConnection(Connectionstring);
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "IsyeriTalep_Ekle_Guncelle";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = cnn;

            cmd.Parameters.Add("@islem", SqlDbType.Int).Value = islem;
            cmd.Parameters.Add("@emlakdurumu", SqlDbType.Int).Value = newIsyeriTalep.EmlakDurumu;
            cmd.Parameters.Add("@tipi", SqlDbType.Int).Value = newIsyeriTalep.IsyeriTuru;
            cmd.Parameters.Add("@binakat1", SqlDbType.Int).Value = newIsyeriTalep.BinaKat1;
            cmd.Parameters.Add("@binakat2", SqlDbType.Int).Value = newIsyeriTalep.BinaKat2;
            cmd.Parameters.Add("@isinmasekli", SqlDbType.Int).Value = newIsyeriTalep.IsinmaSekli;
            cmd.Parameters.Add("@metrekare1", SqlDbType.Int).Value = newIsyeriTalep.Metrekare1;
            cmd.Parameters.Add("@metrekare2", SqlDbType.Int).Value = newIsyeriTalep.Metrekare2;
            cmd.Parameters.Add("@odasayisi1", SqlDbType.Int).Value = newIsyeriTalep.OdaSayisi1;
            cmd.Parameters.Add("@odasayisi2", SqlDbType.Int).Value = newIsyeriTalep.OdaSayisi2;
            cmd.Parameters.Add("@fiyat1", SqlDbType.Money).Value = newIsyeriTalep.Fiyat1;
            cmd.Parameters.Add("@fiyat2", SqlDbType.Money).Value = newIsyeriTalep.Fiyat2;
            cmd.Parameters.Add("@kira1", SqlDbType.Money).Value = DBNull.Value;
            cmd.Parameters.Add("@kira2", SqlDbType.Money).Value = DBNull.Value;
            cmd.Parameters.Add("@aciklama", SqlDbType.NChar, 200).Value = newIsyeriTalep.Aciklama;
            cmd.Parameters.Add("@kayittarihi", SqlDbType.DateTime).Value = newIsyeriTalep.KayitTarihi;
            cmd.Parameters.Add("@sondegisikligiyapan", SqlDbType.Int).Value = DBNull.Value;
            cmd.Parameters.Add("@sondegisikliktarihi", SqlDbType.DateTime).Value = DBNull.Value;
            cmd.Parameters.Add("@dovizkuru", SqlDbType.Int).Value = newIsyeriTalep.DovizTuru;
            cmd.Parameters.Add("@il", SqlDbType.NChar, 20).Value = newIsyeriTalep.Il;
            cmd.Parameters.Add("@ilce", SqlDbType.NChar, 30).Value = newIsyeriTalep.Ilce;
            cmd.Parameters.Add("@semt", SqlDbType.NChar, 30).Value = newIsyeriTalep.SemtMahalle;
            //cmd.Parameters.Add("@tc", SqlDbType.NChar, 11).Value = newIsyeriTalep
            //cmd.Parameters.Add("@tabloadi", SqlDbType.NChar, 20).Value = newIsyeriTalep


            try
            {
                cnn.Open();
                cmd.ExecuteNonQuery();
                cnn.Dispose();
                cnn.Close();
            }
            catch (Exception ex) { }

            return 0;
        }

        static public int Not_Ekle_Guncelle(frmNotlar newNot, int islem)
        {
            SqlConnection cnn = new SqlConnection(Connectionstring);
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "Not_Ekle_Guncelle";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = cnn;

            cmd.Parameters.Add("@islem", SqlDbType.Int).Value = islem;
            cmd.Parameters.Add("@personelID", SqlDbType.Int).Value = newNot.PersonelID;
            cmd.Parameters.Add("@notu", SqlDbType.NChar, 300).Value = newNot.Notu;
            cmd.Parameters.Add("@kayittarihi", SqlDbType.DateTime).Value = newNot.Kayittarihi;
            cmd.Parameters.Add("@sondegisikligiyapan", SqlDbType.Int).Value = newNot.Degisiklikyapan;
            cmd.Parameters.Add("@sondegisikliktarihi", SqlDbType.DateTime).Value = newNot.Sondegisikliktarihi;


            try
            {
                cnn.Open();
                cmd.ExecuteNonQuery();
                cnn.Dispose();
                cnn.Close();
            }
            catch (Exception ex) { }

            return 0;
        }
    }
}
